package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.GxPatient;
import com.ruoyi.system.service.IGxPatientService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GxTaskData;
import com.ruoyi.system.service.IGxTaskDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * task_dataController
 * 
 * @author ruoyi
 * @date 2022-04-24
 */
@RestController
@RequestMapping("/system/task")
public class GxTaskDataController extends BaseController
{
    @Autowired
    private IGxTaskDataService gxTaskDataService;

    @Autowired
    private IGxPatientService gxPatientService;

    /**
     * 查询全部task_data列表
     */
    @GetMapping("/list")
    public TableDataInfo list(GxTaskData gxTaskData)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.selectGxTaskDataList(gxTaskData);
        return getDataTable(list);
    }

    /**
     * 查询某患者所有已评估任务列表
     */
    @GetMapping("/listAll")
    public TableDataInfo listAll(GxTaskData gxTaskData)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.selectGxTaskDataListAll(gxTaskData);
        return getDataTable(list);
    }

    /**
     * 查询首页评估（日）的 task_data列表
     */
    @GetMapping("/dayList")
    public TableDataInfo dayList(GxTaskData gxTaskData)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.dayGxTaskDataList(gxTaskData);
        return getDataTable(list);
    }
    @GetMapping("/dayListStatus")
    public TableDataInfo dayListByStatus(GxTaskData gxTaskData)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.dayGxTaskDataListByStatus(gxTaskData);
        return getDataTable(list);
    }
    @GetMapping("/dayList14")
    public TableDataInfo dayList14(GxTaskData gxTaskData)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.dayGxTaskDataList14(gxTaskData);
        return getDataTable(list);
    }
    @GetMapping("/dayListStatus14")
    public TableDataInfo dayListByStatus14(GxTaskData gxTaskData)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.dayGxTaskDataListByStatus14(gxTaskData);
        return getDataTable(list);
    }
    /**
     * 查询首页评估（周）的 task_data列表
     */
    @GetMapping("/weekList")
    public TableDataInfo weekList(GxTaskData gxTaskData)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.weekGxTaskDataList(gxTaskData);
        return getDataTable(list);
    }
    @GetMapping("/weekListStatus")
    public TableDataInfo weekListByStatus(GxTaskData gxTaskData)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.weekGxTaskDataListByStatus(gxTaskData);
        return getDataTable(list);
    }
    @GetMapping("/weekList14")
    public TableDataInfo weekList14(GxTaskData gxTaskData)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.weekGxTaskDataList14(gxTaskData);
        return getDataTable(list);
    }
    @GetMapping("/weekListStatus14")
    public TableDataInfo weekListByStatus14(GxTaskData gxTaskData)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.weekGxTaskDataListByStatus14(gxTaskData);
        return getDataTable(list);
    }

    /**
     * 查询审核功能中全部task_data列表
     */
    @GetMapping("/listAudit")
    public TableDataInfo listAudit(GxTaskData gxTaskData)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.auditGxTaskDataList(gxTaskData);
        return getDataTable(list);
    }

    /**
     * 查询审核功能中全部task_data列表
     */
    @GetMapping("/listAuditByDept/{deptId}")
    public TableDataInfo listAuditByDept(@PathVariable("deptId") Long deptId)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.auditGxTaskDataListByDept(deptId);
        return getDataTable(list);
    }

    /**
     * 查询在院者task_data列表
     */
    @GetMapping("/listalive")
    public TableDataInfo listalive(GxTaskData gxTaskData)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.selectGxTaskDataListalive(gxTaskData);
        return getDataTable(list);
    }

    @GetMapping("/listByDept/{deptId}")
    public TableDataInfo listByDept(@PathVariable("deptId") Long deptId)
    {
        startPage();
        List<GxTaskData> list = gxTaskDataService.selectGxTaskDataByDept(deptId);
        return getDataTable(list);
    }

    /**
     * 导出task_data列表
     */
    @Log(title = "task_data", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GxTaskData gxTaskData)
    {
        List<GxTaskData> list = gxTaskDataService.selectGxTaskDataList(gxTaskData);
        ExcelUtil<GxTaskData> util = new ExcelUtil<GxTaskData>(GxTaskData.class);
        util.exportExcel(response, list, "task_data数据");
    }

    /**
     * 获取task_data详细信息
     */
    @GetMapping(value = "/{taskId}")
    public AjaxResult getInfo(@PathVariable(value = "taskId") Long taskId)
    {
        return AjaxResult.success(gxTaskDataService.selectGxTaskDataByTaskId(taskId));
    }

    /**
     * 新增task_data
     */
    @Log(title = "task_data", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GxTaskData gxTaskData)
    {
        return toAjax(gxTaskDataService.insertGxTaskData(gxTaskData));
    }

    /**
     * 修改task_data
     */
    @Log(title = "task_data", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GxTaskData gxTaskData)
    {
        return toAjax(gxTaskDataService.updateGxTaskData(gxTaskData));
    }

    /**
     * 删除task_data
     */
    @Log(title = "task_data", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taskIds}")
    public AjaxResult remove(@PathVariable Long[] taskIds)
    {
        return toAjax(gxTaskDataService.deleteGxTaskDataByTaskIds(taskIds));
    }

    /**
     * 添加task_data
     */
    @Log(title = "task_data", businessType = BusinessType.DELETE)
    @DeleteMapping("/data/{taskIds}")
    public AjaxResult addData(@PathVariable Long[] taskIds)
    {
        return toAjax(gxTaskDataService.deleteGxTaskDataByTaskIds(taskIds));
    }
}
